<?php
class ContentAction extends Action{
	//大赛介绍
	public function Introduce(){
		$getid=$this->_get('id');
		$m= M('content');
		$content=$m->where("ColumnId={$getid}")->order("id desc")->find();
		$this->assign('content',$content['Content']);
		$this->display();
	}
	//企业教官和指导老师列表
	public function Namelist(){
		$getid=$this->_get('type');
		import('ORG.Util.Page');
		$m=M('users');
		$count=$m->where("UserType={$getid}")->count();
		$page=new page($count,30);
		$show=$page->show();
		$list=$m->where("UserType={$getid}")->order('UserId')->limit($page->firstRow.','.$page->listRows)->select();
		switch($getid){
			case 3:
				$title['t1']='大赛教师名单列表';
				$title['t2']='教师姓名';
				$title['t3']='所在学校';			
			break;
			case 4:
				$title['t1']='大赛企业教官名单列表';
				$title['t2']='教官姓名';
				$title['t3']='所在企业';
			break;
		}
		$this->assign('page',$show);
		$this->assign('title',$title);
		$this->assign('list',$list);
		//dump($list);
		$this->display();
	}
	//大赛公告
	public function Notice(){
		$getid=$this->_get('id');
		//$pid=$this->_get('pid');
		$column=new Model();
	/* 	//判断是id是parent还是son
		if($pid==NULL){	
			$clist=$column->query("SELECT Id,Name,ParentColumnId FROM `column` WHERE ParentColumnId={$getid}");
		}else{
			$clist=$column->query("SELECT Id,Name,ParentColumnId FROM `column` WHERE ParentColumnId={$pid}");
		}  */
		$clist=$column->query("SELECT Id,Name,ParentColumnId FROM `column` WHERE ParentColumnId={$getid}");
		import('ORG.Util.Page');	//导入分页类
		$m=M('content');
		$count=$m->where("ColumnId={$getid}")->count();//获取总数
		$page=new page($count,20);		//传入总数与每页显示数
		$show=$page->show();			//分页显示输出
		$list=$m->where("ColumnId={$getid} and IsPublished='1'")->order('CreateDate desc')->limit($page->firstRow.','.$page->listRows)->select();
		$this->assign('clist',$clist);	//栏目输出
		$this->assign('page',$show);	//分页输出
		$this->assign('list',$list);	//数据集输出
		$this->display();
	}
	//文章内容
	public function Article(){
		$getid=$this->_get('id');
		$m=M('Content');
		$m->where("Id={$getid}")->setInc('ViewCount',1); 
		$article=$m->where("Id={$getid}")->find();
		
		$this->assign('article',$article);
		$RelevantArticle = M('content')->limit(10)->select();
		$this->assign('RelevantArticle',$RelevantArticle);
		$this->display(); 
	}
	//动态快报
	public function Announcement(){
		$getid=$this->_get('id');
		//$pid=$this->_get('pid');
		$column=new Model();
		/* //判断是id是parent还是son
		if($pid==NULL){	
			$clist=$column->query("SELECT Id,Name,ParentColumnId FROM `column` WHERE ParentColumnId={$getid}");
		}else{
			$clist=$column->query("SELECT Id,Name,ParentColumnId FROM `column` WHERE ParentColumnId={$pid}");
		}  */
		$clist=$column->query("SELECT Id,Name,ParentColumnId FROM `column` WHERE ParentColumnId={$getid}");
		import('ORG.Util.Page');	//导入分页类
		$m=M('content');
		$count=$m->where("ColumnId={$getid}")->count();//获取总数
		$page=new page($count,20);		//传入总数与每页显示数
		$show=$page->show();			//分页显示输出
		$list=$m->where("ColumnId={$getid} and IsPublished='1'")->order('CreateDate desc')->limit($page->firstRow.','.$page->listRows)->select();
		$this->assign('clist',$clist);	//栏目输出
		$this->assign('page',$show);	//分页输出
		$this->assign('list',$list);	//数据集输出
		$this->display();
	}
}